## Managed by salt ##
#
# slurm.conf SLURM config file
#

{% set slurm_conf = pillar.get('slurm', {}) -%}

{%- macro slurmconf(field, default) -%}
{%- if field in slurm_conf -%}
{{field}}={{slurm_conf.get(field)}}
{% else -%}
# {{field}}={{default}}
{% endif -%}
{%- endmacro -%}

{%- macro slurmconf_always(field, default) -%}
{%- if field in slurm_conf -%}
{{field}}={{slurm_conf.get(field)}}
{% else -%}
{{field}}={{default}}
{% endif -%}
{%- endmacro -%}

{%- macro slurmconf_prefix(field, default, prefix) -%}
{%- if field in slurm_conf -%}
{{field}}={{prefix}}/{{slurm_conf.get(field)}}
{% else -%}
# {{field}}={{prefix}}/{{default}}
{% endif -%}
{%- endmacro -%}

{%- macro slurmconf_prefix_list(field, default, prefix) -%}
{%- if field in slurm_conf -%}
{{field}}={{prefix}}/{{slurm_conf.get(field)|join(','+prefix+'/')}}
{% else -%}
{%- if default=='' -%}
# {{field}}=
{% else -%}
# {{field}}={{prefix}}/{{default}}
{% endif -%}
{%- endif -%}
{%- endmacro -%}

## BASIC CONFIGURATION
ClusterName={{ slurm_conf.ClusterName }}
ControlMachine={{ slurm_conf.ControlMachine }}
{{ slurmconf('ControlAddr',slurm_conf.ControlMachine) -}}
{{ slurmconf('BackupController','') -}}
{{ slurmconf('BackupAddr','') -}}
{{ slurmconf('GresTypes', '') -}}

SlurmUser=slurm
{{ slurmconf('SlurmdUser', 'root') -}}
{{ slurmconf('SlurmctldPort', '6817') -}}
{{ slurmconf('SlurmdPort', '6818') -}}
{{ slurmconf('SrunPortRange', '') -}}
{{ slurmconf_always('SlurmdSpoolDir', slurm.slurmddir) }}
{{ slurmconf_always('StateSaveLocation', slurm.slurmctlddir) }}
{{ slurmconf_always('JobCheckpointDir', slurm.slurmctlddir) }}
{{ slurmconf_always('SlurmctldPidFile', slurm.rundir + '/slurmctld.pid') }}
{{ slurmconf_always('SlurmdPidFile', slurm.rundir + '/slurmd.pid') }}
{{ slurmconf_always('PluginDir', slurm.plugindir) }}
{{ slurmconf('SlurmdParameters', '') -}}
{{ slurmconf('SlurmctldParameters', '') -}}
{{ slurmconf('PlugStackConfig', '') -}}
{{ slurmconf('SlurmctldPlugstack', '') -}}
{{ slurmconf('SlurmctldPrimaryOffProg', '') -}}
{{ slurmconf('SlurmctldPrimaryOnProg', '') -}}
{{ slurmconf_prefix('AuthType', 'munge', 'auth') -}}
{{ slurmconf_prefix('AuthAltType', 'none', 'auth') -}}
{{ slurmconf('AuthInfo', '') -}}
{{ slurmconf_prefix('CryptoType', 'munge', 'crypto') -}}
{{ slurmconf('ReconfigFlags', '') -}}
{{ '' }}
{{ slurmconf('JobCredentialPrivateKey', '') -}}
{{ slurmconf('JobCredentialPublicCertificate', '') -}}
{{ '' }}
{{ slurmconf_always('MailProg', slurm.mail) -}}
{{ slurmconf('MailDomain', '') -}}
{{ slurmconf('ReturnToService', '0') -}}
{{ slurmconf('DisableRootJobs', 'NO') -}}
{{ slurmconf('EnforcePartLimits', 'NO') -}}
{{ slurmconf('JobRequeue', '1') -}}
{{ slurmconf('RequeueExit', '') -}}
{{ slurmconf('RequeueExitHold', '') -}}
{{ slurmconf('JobFileAppend', '0') -}}
{{ slurmconf_prefix_list('JobSubmitPlugins', '', 'job_submit') -}}
{{ slurmconf_prefix_list('CliFilterPlugins', '', 'cli_filter') -}}
{{ slurmconf('KillOnBadExit', '0') -}}
{{ slurmconf('PrivateData', '') -}}
{{ slurmconf('CacheGroups','0') -}}
{{ slurmconf('GroupUpdateForce', '0') -}}
{{ slurmconf('GroupUpdateTime', '600') -}}
{{ slurmconf_prefix('ProctrackType', 'pgid', 'proctrack') }}
{{ slurmconf('PropagateResourceLimits', 'ALL') -}}
{{ slurmconf('PropagateResourceLimitsExcept', '') -}}
{{ slurmconf('PropagatePrioProcess', '0') -}}
{{ slurmconf('Prolog', '') -}}
{{ slurmconf('PrologFlags', '') -}}
{{ slurmconf('Epilog', '') -}}
{{ slurmconf('SrunEpilog', '') -}}
{{ slurmconf('SrunProlog', '') -}}
{{ slurmconf('TaskProlog', '') -}}
{{ slurmconf('TaskEpilog', '') -}}
{{ slurmconf('PrologEpilogTimeout', '0') -}}
{{ slurmconf_prefix_list('TaskPlugin', 'none', 'task') -}}
{{ slurmconf('TaskPluginParam', '') -}}
{{ slurmconf('PrologSlurmctld', '') -}}
{{ slurmconf('EpilogSlurmctld', '') -}}
{{ slurmconf('SallocDefaultCommand', '') -}}
{{ slurmconf_prefix('CheckpointType', 'none', 'checkpoint') }}
{{ slurmconf('FirstJobId', '1') -}}
{{ slurmconf('MaxJobId', '2147418112') -}}
{{ slurmconf('MaxArraySize', '1001') -}}
{{ slurmconf('MaxJobCount', '10000') -}}
{{ slurmconf('MaxStepCount', '40000') -}}
{{ slurmconf('MaxTasksPerNode', '128') -}}
{{ slurmconf('MaxDBDMsgs', '10000') -}}
{{ slurmconf('UnkillableStepProgram', '') -}}
{{ slurmconf('MpiDefault', 'none') -}}
{{ slurmconf('MpiParams', '') -}}
{{ slurmconf('TmpFs', '/tmp') -}}
{{ slurmconf('TrackWCKey', 'no') -}}
{{ slurmconf('TreeWidth', '50') -}}
{{ slurmconf('UsePAM', '0') -}}
{{ slurmconf('CommunicationParameters', '') -}}
{{ slurmconf_prefix('CoreSpecPlugin', 'none', 'core_spec') -}}
{{ slurmconf('CpuFreqDef', '') -}}
{{ slurmconf('CpuFreqGovernors', '') -}}
{{ slurmconf('GpuFreqDef', '') -}}
{{ slurmconf_prefix('LaunchType', 'slurm', 'launch') -}}
{{ slurmconf('LaunchParameters', '') -}}
{{ slurmconf_prefix('MCSPlugin', 'none', 'mcs') -}}
{{ slurmconf('MCSParameters', '') -}}
{{ slurmconf_prefix('RoutePlugin', 'default', 'route') -}}
{{ slurmconf('MsgAggregationParams', '') -}}
{{ slurmconf('SbcastParameters', '') -}}
{{ slurmconf('X11Parameters', '') -}}

## HEALTH
{{ slurmconf('HealthCheckInterval', '0') -}}
{{ slurmconf('HealthCheckNodeState', 'ANY') -}}
{{ slurmconf('HealthCheckProgram', '') -}}

## Sensors
{{ slurmconf_prefix('ExtSensorsType', none, 'ext_sensors') -}}
{{ slurmconf('ExtSensorsFreq', '0') -}}

## SWITCHES
{{ slurmconf_prefix('SwitchType', 'none', 'switch') -}}
{{ slurmconf_prefix('TopologyPlugin', 'none', 'topology') -}}
{{ slurmconf('TopologyParam', '') -}}

## TIMERS
{{ slurmconf('SlurmctldTimeout','120') -}}
{{ slurmconf('SlurmdTimeout','300') -}}
{{ slurmconf('InactiveLimit','0') -}}
{{ slurmconf('MinJobAge', '300') -}}
{{ slurmconf('KillWait', '30') -}}
{{ slurmconf('Waittime', '0') -}}
{{ slurmconf('EioTimeout', '60') -}}

{{ slurmconf('BatchStartTimeout','10') -}}
{{ slurmconf('CompleteWait', '0') -}}
{{ slurmconf('MessageTimeout', '10') -}}
{{ slurmconf('TCPTimeout', '2') -}}
{{ slurmconf('UnkillableStepTimeout', '60') -}}
{{ slurmconf('EpilogMsgTime', '2000') -}}
{{ slurmconf('GetEnvTimeout', '2') -}}
{{ slurmconf('KeepAliveTime', '') -}}
{{ slurmconf('OverTimeLimit', '0') -}}

## RESERVATIONS
{{ slurmconf('ResvOverRun', '0') -}}
{{ slurmconf('ResvProlog', '') -}}
{{ slurmconf('ResvEpilog', '') -}}

## SCHEDULING
{{ slurmconf_prefix('SchedulerType','backfill', 'sched') -}}
{{ slurmconf_prefix('SelectType','linear', 'select') -}}
{{ slurmconf('SelectTypeParameters', 'CR_CPU') -}}
{{ slurmconf('FastSchedule', '1') -}}
{{ slurmconf('SchedulerParameters', '') -}}
{{ slurmconf('SchedulerTimeSlice', '30') -}}
{{ slurmconf('SchedulerPort', '7321') -}}
{{ slurmconf('DefMemPerNode', '0') -}}
{{ slurmconf('DefMemPerCPU', '0') -}}
{{ slurmconf('MaxMemPerCPU', '0') -}}
{{ slurmconf('DefCpuPerGPU', '0') -}}
{{ slurmconf('DefMemPerGPU', '0') -}}
{{ slurmconf('VSizeFactor', '0') -}}
{{ slurmconf('AlowSpecResourceUsage', 'NO') -}}

{{ slurmconf_prefix('PreemptType', 'none', 'preempt') }}
{{ slurmconf('PreemptMode', 'OFF') }}
{{ slurmconf('PreemptExemptTime', '0') }}
{{ slurmconf('Licenses', '') }}

{{ slurmconf_prefix('PriorityType', 'basic', 'priority') -}}
{{ slurmconf('PriorityDecayHalfLife', '7-0') -}}
{{ slurmconf('PriorityCalcPeriod', '5') -}}
{{ slurmconf('PriorityFavorSmall', 'NO') -}}
{{ slurmconf('PriorityFlags', '') -}}
{{ slurmconf('PriorityParameters', '') -}}
{{ slurmconf_prefix('PrioritySiteFactorPlugin', 'none', 'site_factor') -}}
{{ slurmconf('PrioritySiteFactorParameters', '') -}}
{{ slurmconf('PriorityMaxAge', '7-0') -}}
{{ slurmconf('PriorityUsageResetPeriod', 'NONE') -}}
{{ slurmconf('PriorityWeightAge', '0') -}}
{{ slurmconf('PriorityWeightFairshare', '0') -}}
{{ slurmconf('PriorityWeightJobSize', '0') -}}
{{ slurmconf('PriorityWeightPartition', '0') -}}
{{ slurmconf('PriorityWeightQOS', '0') -}}
{{ slurmconf('PriorityWeightTRES', '') -}}
{{ slurmconf('FairShareDampeningFactor', '1') -}}



## LOGGING
{{ slurmconf('SlurmctldDebug', 'info') -}}
{{ slurmconf('SlurmdDebug', 'info') -}}
{{ slurmconf('SlurmSchedLogLevel', '0') -}}
{{ slurmconf_always('SlurmctldLogFile', slurm.logdir + '/slurmctld.log') -}}
{{ slurmconf_always('SlurmdLogFile', slurm.logdir + '/slurmd.log') }}
{{ slurmconf_always('SlurmSchedLogFile', slurm.logdir + '/slurm_sched.log') -}}
{{ slurmconf('DebugFlags', '') -}}
{{ slurmconf('LogTimeFormat', 'iso8601_ms') -}}

{{ slurmconf_prefix('JobCompType', 'none', 'jobcomp') -}}
{{ slurmconf('JobCompParams', '') -}}
{{ slurmconf('JobCompLoc', '') -}}
{{ slurmconf('JobCompHost', '') -}}
{{ slurmconf('JobCompUser', '') -}}
{{ slurmconf('JobCompPass', '') -}}
{{ slurmconf('JobCompPort', '') -}}


## ACCOUNTING
{{ slurmconf_prefix('JobAcctGatherType', 'none', 'jobacct_gather') -}}
{{ slurmconf('JobAcctGatherFrequency', '') -}}
{{ slurmconf('JobAcctGatherParams', '') -}}

{{ slurmconf_prefix('AccountingStorageType', 'none', 'accounting_storage') -}}
{{ slurmconf('AccountingStorageHost', '') -}}
{{ slurmconf('AccountingStorageBackupHost', '') -}}
{{ slurmconf('AccountingStoragePort', '') -}}
{{ slurmconf('AccountingStorageLoc', '') -}}
{{ slurmconf('AccountingStorageUser', '') -}}
{{ slurmconf('AccountingStoragePass', '') -}}
{{ slurmconf('AccountingStoreJobComment', 'YES') -}}
{{ slurmconf('AccountingStorageTRES', '') -}}
{{ slurmconf('AccountingStorageEnforce', '') -}}
{{ '' }}
{{ slurmconf_prefix('AcctGatherEnergyType', 'none', 'acct_gather_energy') -}}
{{ slurmconf('AcctGatherNodeFreq', '0') -}}
{{ slurmconf_prefix('AcctGatherInfinibandType', 'none', 'acct_gather_infiniband') -}}
{{ slurmconf_prefix('AcctGatherInterconnectType', 'none', 'acct_gather_interconnect') -}}
{{ slurmconf_prefix('AcctGatherFilesystemType', 'none', 'acct_gather_filesystem') -}}
{{ slurmconf_prefix('AcctGatherProfileType', 'none', 'acct_gather_profile') -}}
{{ slurmconf('DefaultStorageHost', '') -}}
{{ slurmconf('DefaultStorageLoc', '') -}}
{{ slurmconf('DefaultStoragePass', '') -}}
{{ slurmconf('DefaultStoragePort', '') -}}
{{ slurmconf('DefaultStorageType', '') -}}
{{ slurmconf('DefaultStorageUser', '') -}}

## POWER SAVE SUPPORT FOR IDLE NODES
{{ slurmconf('RebootProgram', '') -}}
{{ slurmconf('SuspendProgram', '') -}}
{{ slurmconf('ResumeProgram', '') -}}
{{ slurmconf('ResumeFailProgram', '') -}}
{{ slurmconf('SuspendTimeout', '') -}}
{{ slurmconf('ResumeTimeout', '') -}}
{{ slurmconf('ResumeRate', '') -}}
{{ slurmconf('SuspendExcNodes', '') -}}
{{ slurmconf('SuspendExcParts', '') -}}
{{ slurmconf('SuspendRate', '') -}}
{{ slurmconf('SuspendTime', '') -}}
{{ slurmconf_prefix('NodeFeaturesPlugin', 'none', 'node_features') -}}
{{ slurmconf('PowerParameters', '') -}}
{{ slurmconf_prefix('PowerPlugin', 'none', 'power') -}}


## CHECKPOINTING


## COMPUTE NODES
{% if pillar['slurm']['nodes'] is defined -%}
{%- for node, nodeinfo in pillar['slurm']['nodes'] | dictsort %}
NodeName={{ node }} {% for key, value in nodeinfo.iteritems()  %} {{ key }}={{ value }} {% endfor -%}
{% endfor -%}
{% endif %}

## PARTITIONS
{% if pillar['slurm']['partitions'] is defined -%}
{% set nodes=[] %}
{% for partition, partinfo in pillar['slurm']['partitions'] | dictsort -%}
PartitionName={{ partition }} {% for key, value in partinfo.iteritems() %} {% if key == 'nodes' %} Nodes={{ ','.join(value) }} {% else %}  {{ key }}={{ value }} {% endif %} {% endfor %}
{% endfor -%}
{% endif -%}


